package com.blakebarrett.model.media
{
	[Bindable]
	public class ScalarMediaInfo
	{
		private static const MAXIMUM_PIXELS : Number = 0xFFFFFF;
		
		public static function maxWidth(originalWidth:Number, originalHeight:Number) : Number {
			return Math.min( (MAXIMUM_PIXELS * (originalWidth / originalHeight)), originalWidth );
		}
		
		public static function maxHeight(originalWidth:Number, originalHeight:Number) : Number {
			if ( ( originalWidth * originalHeight ) > MAXIMUM_PIXELS ) {
				return ( MAXIMUM_PIXELS * (originalHeight / originalWidth) );
			} else {
				return ( originalHeight );
			}
		}
		
		public static function minWidth( regionWidth:Number ) : Number {
			return regionWidth;
		}
		
		public static function minHeight( regionHeight:Number ) : Number {
			return regionHeight;
		}
		
		public static function scaleMediaToRegion ( originalWidth:Number, originalHeight:Number, regionWidth:Number, regionHeight:Number ) : Number {
			if ( regionWidth > regionHeight ) {
				return regionWidth / originalWidth;
			} else {
				return regionHeight / originalHeight;
			}
		}
		
		public static function aspectRatio ( wid:Number, hei:Number ) : Number {
			return (wid/hei);
		}

	}
}